Skip to content

Conversation

AZero13
Copy link
Contributor

@AZero13 AZero13 commented Oct 12, 2025

Now we process everything in topological order, the manual sorting and workarounds can be removed.

Now we process everything in topological order, the manual sorting and workarounds can be removed.
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Oct 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 12, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

Changes

Now we process everything in topological order, the manual sorting and workarounds can be removed.


Full diff: https://github.com/llvm/llvm-project/pull/163092.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (-36)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b23b190ea055b..1be272d3922be 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -11340,42 +11340,6 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
   if (SDValue NarrowLoad = reduceLoadWidth(N))
     return NarrowLoad;
 
-  // Here is a common situation. We want to optimize:
-  //
-  //   %a = ...
-  //   %b = and i32 %a, 2
-  //   %c = srl i32 %b, 1
-  //   brcond i32 %c ...
-  //
-  // into
-  //
-  //   %a = ...
-  //   %b = and %a, 2
-  //   %c = setcc eq %b, 0
-  //   brcond %c ...
-  //
-  // However when after the source operand of SRL is optimized into AND, the SRL
-  // itself may not be optimized further. Look for it and add the BRCOND into
-  // the worklist.
-  //
-  // The also tends to happen for binary operations when SimplifyDemandedBits
-  // is involved.
-  //
-  // FIXME: This is unecessary if we process the DAG in topological order,
-  // which we plan to do. This workaround can be removed once the DAG is
-  // processed in topological order.
-  if (N->hasOneUse()) {
-    SDNode *User = *N->user_begin();
-
-    // Look pass the truncate.
-    if (User->getOpcode() == ISD::TRUNCATE && User->hasOneUse())
-      User = *User->user_begin();
-
-    if (User->getOpcode() == ISD::BRCOND || User->getOpcode() == ISD::AND ||
-        User->getOpcode() == ISD::OR || User->getOpcode() == ISD::XOR)
-      AddToWorklist(User);
-  }
-
   // Try to transform this shift into a multiply-high if
   // it matches the appropriate pattern detected in combineShiftToMULH.
   if (SDValue MULH = combineShiftToMULH(N, DL, DAG, TLI))

@AZero13 AZero13 closed this Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:SelectionDAG SelectionDAGISel as well

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants